package pkg

import (
	"fmt"
	"github.com/golang-jwt/jwt/v5"
	"time"
)

type MyCustomClaims struct {
	UserId uint `json:"user_id"`
	jwt.RegisteredClaims
}

func CreateJwtToken(userId uint32, dataTime time.Duration, tokenStr string) interface{} {

	// Create claims with multiple fields populated
	claims := MyCustomClaims{
		uint(userId),
		jwt.RegisteredClaims{
			// A usual scenario is to set the expiration time relative to the current time
			ExpiresAt: jwt.NewNumericDate(time.Now().Add(dataTime)),
		},
	}

	token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
	ss, err := token.SignedString(tokenStr)
	fmt.Println(ss, err)
	return ss
}
